package com.sayice.robotconflict.common.result;

import com.sayice.robotconflict.common.exception.ErrorCode;

/**
 * 响应结果
 *
 * @author shubing
 */
public class ApiResult {
    /**
     * 成功
     */
    public static final ApiResult SUCCESS = new ApiResult(ErrorCode.CODE_200, null);
    
    /**
     * 错误码
     */
    private int code;
    
    /**
     * 信息
     */
    private String msg;
    
    /**
     * 数据
     */
    private Object data;
    
    public ApiResult(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    
    public ApiResult(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    
    /**
     * 创建成功结果
     *
     * @param data 数据
     */
    public static ApiResult successOf(Object data) {
        return new ApiResult(ErrorCode.CODE_200, null, data);
    }
    
    public int getCode() {
        return code;
    }
    
    public void setCode(int code) {
        this.code = code;
    }
    
    public String getMsg() {
        return msg;
    }
    
    public void setMsg(String msg) {
        this.msg = msg;
    }
    
    public Object getData() {
        return data;
    }
    
    public void setData(Object data) {
        this.data = data;
    }
}
